package com.gec.mall.security.service.impl;

import com.gec.mall.mapper.TbUserMapper;
import com.gec.mall.pojo.TbUser;
import com.gec.mall.pojo.TbUserExample;
import com.gec.mall.security.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: li
 * @Date: 2023/2/21
 * @PACKAGE_NAME:com.gec.mall.security.service.impl
 * @Project_Name:mall-parent
 * @VERSION: 1.0.0
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private TbUserMapper userMapper;

    @Override
    public TbUser findUserByUsername(String username) {
        TbUserExample example = new TbUserExample();
        TbUserExample.Criteria criteria = example.createCriteria();
        criteria.andUsernameEqualTo(username);
        List<TbUser> users = userMapper.selectByExample(example);
        if (users.size()>0){
            return users.get(0);
        }
        return null;
    }
}
